package org.example.bookstore.mapper;

import org.apache.ibatis.annotations.*;
import org.example.bookstore.pojo.DO.Book;

import java.util.List;

@Mapper
public interface BookMapper {

    /*
     * 根据书本类型查询书本列表
     * 来查询商品
     * */
    List<Book> selectByType(@Param("type") String type, Integer numFrom , Integer pageSize);

    /*
     * 根据书的类型 小说，励志
     * 来查询商品
     * */
    Integer selectNum(@Param("type") String type);

    /*
     * 根据书本id来查询
     * */
    @Select("select * from books where id=#{id}")
    Book selectById(Integer id);

    /*
     * 根本书本根据数组查询商品列表
     * */
    List<Book> selectByIds(List<Integer> ids);
    /*
     * 根据书本id来删除
     * */
    @Delete("delete  from books where id=#{id}")
    int deleteById(Integer id);
    /*
     * 模糊搜索
     * */
    List<Book> selectByLikeContent(String content);


    int addBook(Book book);

    int updateBook(Book book);

    @Select("SELECT COUNT(*) FROM books")
    int selectAllBook();

    @Select("SELECT COUNT(*) FROM users")
    int selectAllUser();

    @Select("SELECT COUNT(*) FROM `order` WHERE orderType = #{orderType}")
    int selectAllByOrderType(@Param("orderType") int orderType);


}



